//
//  YLInvitingFriendsController.m
//  YLFinanceService
//
//  Created by she1323 on 2017/9/20.
//  Copyright © 2017年 she1323. All rights reserved.
//  邀请好友

#import "YLInvitingFriendsController.h"
#import <Masonry.h>
#import "YLGlobeHeader.h"
#import "YLShareSDK.h"
#import "YLMyInvitationController.h"
@interface YLInvitingFriendsController ()

@end

@implementation YLInvitingFriendsController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    self.title = @"邀请好友 得投资券";
    
    self.view.backgroundColor = YLBackGroundColor;


    __weak typeof(self) weakSelf = self;
    UIButton *invitingButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.view addSubview:invitingButton];
    
    [invitingButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(weakSelf.view);
        make.height.mas_equalTo(44);
      
        if (@available(iOS 11.0, *)) {
         make.bottom.mas_equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom);
        } else {
            make.bottom.mas_equalTo(weakSelf.view);
        }
    }];
    
    invitingButton.backgroundColor = YLLOrgColor;
    [invitingButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [invitingButton setTitle:@"邀请好友" forState:UIControlStateNormal];
    
     UIScrollView *scrollView = [[UIScrollView alloc] init];
    [self.view addSubview:scrollView];
    [scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.left.mas_equalTo(weakSelf.view);
        make.top.mas_equalTo(weakSelf.view);
        make.bottom.mas_equalTo(invitingButton.mas_top);
        
    }];
    
    [invitingButton addTarget:self action:@selector(invitingBuddy) forControlEvents:UIControlEventTouchUpInside];
    
    UIImageView *imageView = [[UIImageView alloc] init];
    imageView.image = [UIImage imageNamed:@"InvitingFriendsBackgroung"];
    [scrollView addSubview:imageView];
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.top.right.left.mas_equalTo(scrollView);
        make.height.mas_equalTo(YLScreenW * 5595 / 2250.0);
        make.width.mas_equalTo(YLScreenW);
    }];
    
    
    UIButton *myInvitingButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.view addSubview:myInvitingButton];
    [myInvitingButton setBackgroundImage:[UIImage imageNamed:@"MyInviting"] forState:UIControlStateNormal];
    [myInvitingButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(weakSelf.view);
        make.width.mas_equalTo(weakSelf.view).multipliedBy(0.3);
        make.height.mas_equalTo(myInvitingButton.mas_width).multipliedBy(120 / 546.0);
        make.top.mas_equalTo(weakSelf.view).mas_offset(60);
    }];
    
    [[myInvitingButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
        YLMyInvitationController *myInvitation = [[YLMyInvitationController alloc] init];
        [weakSelf.navigationController pushViewController:myInvitation animated:YES];
    }];
    

}

- (void)invitingBuddy
{
    [YLShareSDK share];
}

- (void)setUpScrollView
{
   
    

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
